//
//  PageShowCollectionCell.m
//  Food
//
//  Created by dllo on 15/7/14.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "PageShowCollectionCell.h"
#import "UIImageView+WebCache.h"
@implementation PageShowCollectionCell

- (void)dealloc
{
    [_name release];
    [_EgName release];
    [_bottomModel release];
    [_img release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    [super initWithFrame:frame];
    
    if (self) {
        
        self.img = [[[UIImageView alloc] init] autorelease];
        [self.contentView addSubview:self.img];
        
        self.name = [[[UILabel alloc] init] autorelease];
        self.name.textColor = [UIColor whiteColor];
        [self.name setFont:[UIFont fontWithName:@"Helvetica-Bold" size:20]];
        [self.contentView addSubview:self.name];
        
        self.EgName = [[[UILabel alloc] init] autorelease];
        self.EgName.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.EgName];
        
    }
    return  self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    self.img.frame = CGRectMake(0, 0, layoutAttributes.size.width, layoutAttributes.size.height);
    self.name.frame = CGRectMake(10, layoutAttributes.size.height - 75, layoutAttributes.size.width - 60, 25);
    self.EgName.frame = CGRectMake(10, layoutAttributes.size.height - 50, layoutAttributes.size.width - 60, 20);
}

- (void)setBottomModel:(HomePage_Bottom_model *)bottomModel
{
    if (_bottomModel != bottomModel) {
        [_bottomModel release];
        _bottomModel = [bottomModel retain];
    }
    self.name.text = bottomModel.name;
    self.EgName.text = bottomModel.englishName;
    [self.img sd_setImageWithURL:[NSURL URLWithString:bottomModel.imagePathLandscape]];
}

@end
